﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DatabaseAdminTools.MiniForms
{
    public partial class ConfirmForm : Form
    {

        private string option;
        private string key;

        public ConfirmForm(String option, string key)
        {
            InitializeComponent();
            this.option = option;
            this.key = key;
        }

        public void show(Form owner, String text, String caption)
        {
            this.Text = caption;
            label1.Text = text;
            this.Owner = owner;
            this.ShowDialog(owner);
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            button1.Enabled = checkBox1.Checked;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            switch (option)
            {
                case "delete connection":
                    ((Form1)this.Owner).deleteConnection(key);
                    this.Dispose();
                    break;
                case "delete database":
                    ((Form1)this.Owner).deleteDatabase(key);
                    this.Dispose();
                    break;
                case "delete table":
                    this.Dispose();
                    break;
                case "delete user":
                    ((DatabaseAdminTools.OptionForms.UserManagerForm)this.Owner).deleteUser(key);
                    this.Dispose();
                    break;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
